#open(UNFIL,"unfiletered.out") or die "no file found unfiletered.out\n";
#open(R2_03,"CHN_filetered_r2_0_03.out") or die "no file found CHN_filetered_r2_0_03.out\n";
#open(R2_08,"CHN_filetered_r2_0_08.out") or die "no file found CHN_filetered_r2_0_08.out\n";
$unfil=$ARGV[0];
chomp($unfil);
$r2_03=$ARGV[1];
chomp($r2_03);
$r2_08=$ARGV[2];
chomp($r2_08);
open(UNFIL,$unfil) or die "no file found unfil $unfil\n";
open(R2_03,$r2_03) or die "no file found r2_03 $r2_03\n";
open(R2_08,$r2_08) or die "no file found r2_0 $r2_8\n";
#
#
while(<UNFIL>)
{
	chomp($_);
	@a=split("\t",$_);
	if(exists($unfil{$a[3]}))
	{
		$unfil{$a[3]}++;
	}
	else
	{
		$unfil{$a[3]}=1;
	}
}
while(<R2_03>)
{
        chomp($_);
        @a=split("\t",$_);
        if(exists($r2_3{$a[3]}))
        {
                $r2_3{$a[3]}++;
        }
        else
        {
                $r2_3{$a[3]}=1;
        }
}
while(<R2_08>)
{
        chomp($_);
        @a=split("\t",$_);
        if(exists($r2_8{$a[3]}))
        {
                $r2_8{$a[3]}++;
        }
        else
        {
                $r2_8{$a[3]}=1;
        }
}
print "GENE\tUNFILTERED_SNP_COUNT\tFILTERED_R2_0_03\tFILTERED_R2_0_08\n";
while(my($key,$value)=each %unfil)
{
	print $key."\t$value";
	if(exists($r2_3{$key}))
	{
		print "\t$r2_3{$key}";
	}
	else
	{
		print "\t0";
	}
	if(exists($r2_8{$key}))
        {
                print "\t$r2_8{$key}";
        }
        else
        {
                print "\t0";
        }
	print "\n";
}

